home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume18 / olvwm-3.0 / patch2.04 < prev    next >
Encoding:
Text File  |  1992-07-22  |  28.1 KB  |  1,026 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!gatech!paladin.american.edu!darwin.sura.net!mips!msi!dcmartin
  3. From: sdo@soliado.East.Sun.COM (Scott Oaks - Sun Consulting NYC)
  4. Subject: v18i051: olvwm 3.0, Patch2, Part04/04
  5. Message-ID: <1992Jul22.153010.19354@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-18i048-olvwm-3.0@uunet.UU.NET>
  10. Date: Wed, 22 Jul 1992 15:30:10 GMT
  11. Approved: dcmartin@msi.com
  12. Lines: 1012
  13.  
  14. Submitted-by: sdo@soliado.East.Sun.COM (Scott Oaks - Sun Consulting NYC)
  15. Posting-number: Volume 18, Issue 51
  16. Archive-name: olvwm-3.0/patch2.04
  17. Patch-To: olvwm-3.0: Volume 15, Issue 167
  18.  
  19. #!/bin/sh
  20. # this is part.04 (part 4 of a multipart archive)
  21. # do not concatenate these parts, unpack them in order with /bin/sh
  22. # file olvwm3.Patch02 continued
  23. #
  24. if test ! -r _shar_seq_.tmp; then
  25.     echo 'Please unpack part 1 first!'
  26.     exit 1
  27. fi
  28. (read Scheck
  29.  if test "$Scheck" != 4; then
  30.     echo Please unpack part "$Scheck" next!
  31.     exit 1
  32.  else
  33.     exit 0
  34.  fi
  35. ) < _shar_seq_.tmp || exit 1
  36. if test ! -f _shar_wnt_.tmp; then
  37.     echo 'x - still skipping olvwm3.Patch02'
  38. else
  39. echo 'x - continuing file olvwm3.Patch02'
  40. sed 's/^X//' << 'SHAR_EOF' >> 'olvwm3.Patch02' &&
  41. X      if (GRV.VirtualRaiseVDM)
  42. !     RaiseWindow(vdm->client->framewin);
  43. X  }
  44. X  
  45. X  /*
  46. +  * There's another cmpButton in olvwmrc.y, but that comparison checks for
  47. +  * the icon flag and is case insensitive.  We need a simple case sensitive
  48. +  * check here
  49. +  */
  50. + static int
  51. + cmpButton(b1, b2)
  52. +     Button    **b1, **b2;
  53. + {
  54. +     return strcmp(gettext((*b1)->label[0].string),
  55. +           gettext((*b2)->label[0].string));
  56. + }
  57. + /*
  58. X   * Menu generation function for DIRMENU
  59. X   *
  60. X   */
  61. ***************
  62. *** 1797,1803 ****
  63. X  DIR    *dir;
  64. X  struct dirent    *ent;
  65. X  Button    *b;
  66. ! char    s[256], *dirname;
  67. X  extern int AppMenuFunc();
  68. X  
  69. X      MenuInfoDestroy(menuInfo->buttons[bindex].subMenu);
  70. --- 1826,1833 ----
  71. X  DIR    *dir;
  72. X  struct dirent    *ent;
  73. X  Button    *b;
  74. ! char    s[MAXNAMLEN], dirname[MAXPATHLEN - MAXNAMLEN], *newname, *ExpandPath();
  75. ! char    tmp[MAXPATHLEN - MAXNAMLEN], pattern[MAXNAMLEN];
  76. X  extern int AppMenuFunc();
  77. X  
  78. X      MenuInfoDestroy(menuInfo->buttons[bindex].subMenu);
  79. ***************
  80. *** 1811,1825 ****
  81. X      menu->maxLabWidth = 0;
  82. X      menu->prefColSize = 0;
  83. X  
  84. !     dirname = (char *) menuInfo->menu->buttons[bindex]->generate_args;
  85. !     if (!(dir = opendir(dirname))) {
  86. !     menuInfo->buttons[bindex].subMenu =
  87. !                 MenuInfoCreate(cache, winInfo, menu, depth);
  88. !     return;
  89. X      }
  90. X      while (ent = readdir(dir)) {
  91. X      if (ent->d_name[0] == '.')
  92. X          continue;
  93. X      b = (Button *) MemAlloc(sizeof(Button));
  94. X      if (!menu->buttonCount++)
  95. X          menu->buttons = (Button **) MemAlloc(sizeof(Button *));
  96. --- 1841,1873 ----
  97. X      menu->maxLabWidth = 0;
  98. X      menu->prefColSize = 0;
  99. X  
  100. !     pattern[0] = '\0';
  101. !     if ((newname = ExpandPath(menuInfo->menu->buttons[bindex]->generate_args,
  102. !                 True)) == NULL)
  103. !     strcpy(dirname, (char *) menuInfo->menu->buttons[bindex]->generate_args);
  104. !     else {
  105. !     strcpy(dirname, newname);
  106. !     MemFree(newname);
  107. X      }
  108. +     if ((dir = opendir(dirname)) == NULL) {
  109. +     if (newname = strrchr(dirname, '/')) {
  110. +         strcpy(pattern, newname + 1);
  111. +         dirname[strlen(dirname) - strlen(pattern) - 1] = '\0';
  112. +         rexInit(pattern);
  113. +     }
  114. +     if ((newname == NULL) || ((dir = opendir(dirname)) == NULL)) {
  115. +         ErrorWarning(gettext("An invalid directory was named for DIRMENU"));
  116. +         menuInfo->buttons[bindex].subMenu =
  117. +             MenuInfoCreate(cache, winInfo, menu, depth);
  118. +         return;
  119. +     }
  120. +     }
  121. X      while (ent = readdir(dir)) {
  122. X      if (ent->d_name[0] == '.')
  123. X          continue;
  124. +     if (pattern[0] && !rexMatch(ent->d_name))
  125. +         continue;
  126. X      b = (Button *) MemAlloc(sizeof(Button));
  127. X      if (!menu->buttonCount++)
  128. X          menu->buttons = (Button **) MemAlloc(sizeof(Button *));
  129. ***************
  130. *** 1841,1846 ****
  131. --- 1889,1994 ----
  132. X      b->generate_func = NULL;
  133. X      }
  134. X      closedir(dir);
  135. +     if (GRV.VirtualDirSort == SortAlpha)
  136. +     qsort(menu->buttons, menu->buttonCount, sizeof(Button *), cmpButton);
  137. X      menuInfo->buttons[bindex].subMenu =
  138. X                  MenuInfoCreate(cache, winInfo, menu, depth);
  139. + }
  140. + #define INIT   register char *sp = instring;
  141. + #define GETC() (*sp++)
  142. + #define PEEKC()     (*sp)
  143. + #define UNGETC(c)   (--sp)
  144. + #define RETURN(c)   return;
  145. + #define ERROR(val)  regerr(val)
  146. + #define TRUE 1
  147. + #define FALSE 0
  148. + #include <regexp.h>
  149. + static
  150. + regerr(val)
  151. + int val;
  152. + {
  153. +     switch(val) {
  154. +     case 11:
  155. +         ErrorWarning("DIRMENU: Range endpoint too large.\n");
  156. +         break;
  157. +     case 16:
  158. +         ErrorWarning("DIRMENU: Bad number.\n");
  159. +         break;
  160. +     case 25:
  161. +         ErrorWarning("DIRMENU: ``\\ digit'' out of range.\n");
  162. +         break;
  163. +     case 36:
  164. +         ErrorWarning("DIRMENU: Illegal or missing delimiter.\n");
  165. +         break;
  166. +     case 41:
  167. +         ErrorWarning("DIRMENU: No remembered search string.\n");
  168. +         break;
  169. +     case 42:
  170. +         ErrorWarning("DIRMENU: \\( \\) imbalance.\n");
  171. +         break;
  172. +     case 43:
  173. +         ErrorWarning("DIRMENU: Too many \\(.\n");
  174. +         break;
  175. +     case 44:
  176. +         ErrorWarning("DIRMENU: More than 2 numbers given in \\{ \\}.\n");
  177. +         break;
  178. +     case 45:
  179. +         /* { gratutitous brace to match next line for vi */
  180. +         ErrorWarning("DIRMENU: } expected after \\.\n");
  181. +         break;
  182. +     case 46:
  183. +         ErrorWarning("DIRMENU: First number exceeds second in \\{ \\}.\n");
  184. +         break;
  185. +     case 49:
  186. +         ErrorWarning("DIRMENU: [] imbalance.\n");
  187. +         break;
  188. +     case 50:
  189. +         ErrorWarning("DIRMENU: Regular expression too long.\n");
  190. +         break;
  191. +     default:
  192. +         ErrorWarning("DIRMENU: Error code %d returned\n",val);
  193. +         break;
  194. +     }
  195. + }
  196. + static char expbuf[256];
  197. + static
  198. + rexMatch(string)
  199. +     char *string;
  200. + {
  201. +     return step(string,expbuf);
  202. + }
  203. + static
  204. + rexInit(pattern)
  205. +     char *pattern;
  206. + {
  207. + int i, j, n;
  208. + char newPattern[256],tmp[256];
  209. +     strcpy(newPattern,"");
  210. +     n = strlen(pattern);
  211. +     newPattern[0] = '^';
  212. +     for(i = 0, j = 1; i < n; i++) {
  213. +     switch(pattern[i]) {
  214. +         case '?':
  215. +         newPattern[j++] = '.';
  216. +         break;
  217. +         case '*':
  218. +         newPattern[j++] = '.';
  219. +         newPattern[j++] = '*';
  220. +         break;
  221. +         case '.':
  222. +         newPattern[j++] = '\\';
  223. +         newPattern[j++] = '.';
  224. +         break;
  225. +         default:
  226. +         newPattern[j++] = pattern[i];
  227. +     }
  228. +     }
  229. +     newPattern[j++] = '$';
  230. +     compile(newPattern, expbuf, &expbuf[256], '\0');
  231. X  }
  232. *** BUILD/win.h    Sat Jun 13 15:50:19 1992
  233. --- src/win.h    Sat Jun 13 15:43:29 1992
  234. ***************
  235. *** 7,13 ****
  236. X  #ifndef _OLWM_WIN_H
  237. X  #define _OLWM_WIN_H
  238. X  
  239. ! #ident  "@(#)win.h    1.1 olvwm version 1/3/92"
  240. X  
  241. X  /*
  242. X   * Based on
  243. --- 7,13 ----
  244. X  #ifndef _OLWM_WIN_H
  245. X  #define _OLWM_WIN_H
  246. X  
  247. ! #ident  "@(#)win.h    1.2 olvwm version 6/13/92"
  248. X  
  249. X  /*
  250. X   * Based on
  251. ***************
  252. *** 23,30 ****
  253. X      MENU_FULL,     /* Close, Zoom, Props, Scale, Back, Refresh, Quit */
  254. X      MENU_LIMITED,  /* Dismiss, Scale, Refresh */
  255. X      MENU_NONE,
  256. -     MENU_ROOT,       /* used only by usermenu.c */
  257. X      MENU_VDM,       /* used in virtual.c */
  258. X      NUM_MENUS
  259. X  } MenuIndex;
  260. X  
  261. --- 23,33 ----
  262. X      MENU_FULL,     /* Close, Zoom, Props, Scale, Back, Refresh, Quit */
  263. X      MENU_LIMITED,  /* Dismiss, Scale, Refresh */
  264. X      MENU_NONE,
  265. X      MENU_VDM,       /* used in virtual.c */
  266. +     MENU_ROOT,       /* used only by usermenu.c */
  267. +            /* because of rereading menu file, MENU_ROOT must be last
  268. +             * since it has to clear out all menu caches after it
  269. +             */
  270. X      NUM_MENUS
  271. X  } MenuIndex;
  272. X  
  273. ***************
  274. *** 467,472 ****
  275. --- 470,476 ----
  276. X  typedef struct _winvirtual {
  277. X      ClassVirtualPane   *class;
  278. X      WinCore            core;
  279. +     WinPaneCore        pcore;
  280. X  } WinVirtual;
  281. X  
  282. X  typedef enum {upleft, upright, lowleft, lowright, keyevent} WhichResize;
  283. *** BUILD/winbutton.c    Sat Jun 13 15:50:10 1992
  284. --- src/winbutton.c    Sat Jun 13 15:43:29 1992
  285. ***************
  286. *** 4,10 ****
  287. X   *      file for terms of the license.
  288. X   */
  289. X  
  290. ! #ident    "@(#)winbutton.c    1.1 olvwm version 1/3/92"
  291. X  
  292. X  /*
  293. X   * Based on
  294. --- 4,10 ----
  295. X   *      file for terms of the license.
  296. X   */
  297. X  
  298. ! #ident    "@(#)winbutton.c    1.2 olvwm version 6/13/92"
  299. X  
  300. X  /*
  301. X   * Based on
  302. ***************
  303. *** 103,109 ****
  304. X          XGrabPointer(dpy, winInfo->core.self, False,
  305. X           (ButtonReleaseMask | ButtonPressMask | PointerMotionMask),
  306. X           GrabModeAsync, GrabModeAsync, None,
  307. !          GRV.MovePointer, CurrentTime);
  308. X          buttonActive = True;
  309. X          currentAction = a;
  310. X          break;
  311. --- 103,109 ----
  312. X          XGrabPointer(dpy, winInfo->core.self, False,
  313. X           (ButtonReleaseMask | ButtonPressMask | PointerMotionMask),
  314. X           GrabModeAsync, GrabModeAsync, None,
  315. !          GRV.CloseDownPointer, CurrentTime);
  316. X          buttonActive = True;
  317. X          currentAction = a;
  318. X          break;
  319. ***************
  320. *** 174,180 ****
  321. X  
  322. X      if (cli->isFocus)
  323. X          gis = WinGI(winInfo, INPUTFOCUS_GINFO);
  324. !     else gis == WinGI(winInfo,NORMAL_GINFO);
  325. X  
  326. X      if (!event->xmotion.same_screen || currentAction != ACTION_SELECT)
  327. X          return;
  328. --- 174,180 ----
  329. X  
  330. X      if (cli->isFocus)
  331. X          gis = WinGI(winInfo, INPUTFOCUS_GINFO);
  332. !     else gis = WinGI(winInfo,NORMAL_GINFO);
  333. X  
  334. X      if (!event->xmotion.same_screen || currentAction != ACTION_SELECT)
  335. X          return;
  336. ***************
  337. *** 325,331 ****
  338. X  
  339. X          attributes.event_mask =
  340. X          ButtonReleaseMask | ButtonPressMask | ExposureMask;
  341. !     attributes.cursor = GRV.IconPointer;
  342. X          valuemask = CWEventMask | CWCursor;
  343. X  
  344. X          win = XCreateWindow(dpy, par->core.self,
  345. --- 325,331 ----
  346. X  
  347. X          attributes.event_mask =
  348. X          ButtonReleaseMask | ButtonPressMask | ExposureMask;
  349. !     attributes.cursor = GRV.CloseUpPointer;
  350. X          valuemask = CWEventMask | CWCursor;
  351. X  
  352. X          win = XCreateWindow(dpy, par->core.self,
  353. *** BUILD/winframe.c    Sat Jun 13 15:51:10 1992
  354. --- src/winframe.c    Sat Jun 13 15:43:30 1992
  355. ***************
  356. *** 4,10 ****
  357. X   *      file for terms of the license.
  358. X   */
  359. X  
  360. ! #ident    "@(#)winframe.c    1.2 olvwm version 1/27/92"
  361. X  
  362. X  /*
  363. X   * Based on
  364. --- 4,10 ----
  365. X   *      file for terms of the license.
  366. X   */
  367. X  
  368. ! #ident    "@(#)winframe.c    1.3 olvwm version 6/13/92"
  369. X  
  370. X  /*
  371. X   * Based on
  372. ***************
  373. *** 812,819 ****
  374. X      int fy = h-heightBottomFrame(win);
  375. X      int baseline;
  376. X      int margin;
  377. !     int footwidth = w - 2*margin;
  378. !     int qfootwidth = footwidth / 4;
  379. X      int gutter;
  380. X      int rstart, lmaxwidth, rmaxwidth;
  381. X      Graphics_info    *gis;
  382. --- 812,819 ----
  383. X      int fy = h-heightBottomFrame(win);
  384. X      int baseline;
  385. X      int margin;
  386. !     int footwidth;
  387. !     int qfootwidth;
  388. X      int gutter;
  389. X      int rstart, lmaxwidth, rmaxwidth;
  390. X      Graphics_info    *gis;
  391. ***************
  392. *** 834,839 ****
  393. --- 834,841 ----
  394. X      armh = ResizeArm_Height(gis);
  395. X      gutter = ptSize(gis);
  396. X      margin = FRAME_OUTLINE_WIDTH + ptSize(gis);
  397. +     footwidth = w - 2*margin;
  398. +     qfootwidth = footwidth / 4;
  399. X  
  400. X      XFillRectangle(dpy, self, gc,
  401. X          widthLeftFrame(win), fy,
  402. ***************
  403. *** 1532,1538 ****
  404. X      attributes.cursor = GRV.TargetPointer;
  405. X      attributes.border_pixel = 0;
  406. X      attributes.colormap = cli->scrInfo->colormap;
  407. !     if (GRV.PointerWorkspace)
  408. X          valuemask = CWEventMask | CWSaveUnder | CWBackPixmap |
  409. X              CWBorderPixel | CWColormap;
  410. X      else valuemask = CWEventMask | CWSaveUnder | CWBackPixmap | CWCursor |
  411. --- 1534,1540 ----
  412. X      attributes.cursor = GRV.TargetPointer;
  413. X      attributes.border_pixel = 0;
  414. X      attributes.colormap = cli->scrInfo->colormap;
  415. !     if (!GRV.PointerWorkspace)
  416. X          valuemask = CWEventMask | CWSaveUnder | CWBackPixmap |
  417. X              CWBorderPixel | CWColormap;
  418. X      else valuemask = CWEventMask | CWSaveUnder | CWBackPixmap | CWCursor |
  419. *** BUILD/winicon.c    Sat Jun 13 15:50:26 1992
  420. --- src/winicon.c    Sat Jun 13 15:43:30 1992
  421. ***************
  422. *** 4,10 ****
  423. X   *      file for terms of the license.
  424. X   */
  425. X  
  426. ! #ident    "@(#)winicon.c    1.1 olvwm version 1/3/92"
  427. X  
  428. X  /*
  429. X   * Based on
  430. --- 4,10 ----
  431. X   *      file for terms of the license.
  432. X   */
  433. X  
  434. ! #ident    "@(#)winicon.c    1.2 olvwm version 6/13/92"
  435. X  
  436. X  /*
  437. X   * Based on
  438. ***************
  439. *** 731,741 ****
  440. X  {
  441. X      WinIconPane *pane = (WinIconPane *)winIcon->fcore.panewin;
  442. X  
  443. X      XReparentWindow(cli->dpy, pane->core.self, winIcon->core.self,
  444. !             pane->core.x, pane->core.y);
  445. !     XMapWindow(cli->dpy, pane->core.self);
  446. X      if (pane->iconClientWindow && !(cli->flags & CLOlwmOwned))
  447. X          XChangeSaveSet(cli->dpy, pane->core.self, SetModeInsert);
  448. X      MapWindow(winIcon);
  449. X  }
  450. X  
  451. --- 731,744 ----
  452. X  {
  453. X      WinIconPane *pane = (WinIconPane *)winIcon->fcore.panewin;
  454. X  
  455. + #ifdef notdef
  456. +     /* see winipane.c */
  457. X      XReparentWindow(cli->dpy, pane->core.self, winIcon->core.self,
  458. !             pane->core.x, pane->core.y); see winipane.c
  459. X      if (pane->iconClientWindow && !(cli->flags & CLOlwmOwned))
  460. X          XChangeSaveSet(cli->dpy, pane->core.self, SetModeInsert);
  461. + #endif
  462. +     XMapWindow(cli->dpy, pane->core.self);
  463. X      MapWindow(winIcon);
  464. X  }
  465. X  
  466. ***************
  467. *** 752,757 ****
  468. --- 755,778 ----
  469. X      WinIconPane *pane = (WinIconPane *)winIcon->fcore.panewin;
  470. X  
  471. X      UnmapWindow(winIcon);
  472. +     XUnmapWindow(cli->dpy, pane->core.self);
  473. + #ifdef notdef
  474. +     /* see winipane.c */
  475. +     XReparentWindow(cli->dpy, pane->core.self, cli->scrInfo->rootid,
  476. +             winIcon->core.x + pane->core.x,
  477. +             winIcon->core.y + pane->core.y);
  478. +     if (pane->iconClientWindow && !(cli->flags & CLOlwmOwned))
  479. +         XChangeSaveSet(cli->dpy, pane->core.self, SetModeDelete);
  480. + #endif
  481. + }
  482. + void
  483. + IconUnparent(cli, winIcon)
  484. +     Client *cli;
  485. +     WinIconFrame *winIcon;
  486. + {
  487. + WinIconPane *pane = (WinIconPane *)winIcon->fcore.panewin;
  488. X      XUnmapWindow(cli->dpy, pane->core.self);
  489. X      XReparentWindow(cli->dpy, pane->core.self, cli->scrInfo->rootid,
  490. X              winIcon->core.x + pane->core.x,
  491. *** BUILD/winipane.c    Sat Jun 13 15:51:11 1992
  492. --- src/winipane.c    Sat Jun 13 15:43:30 1992
  493. ***************
  494. *** 4,10 ****
  495. X   *      file for terms of the license.
  496. X   */
  497. X  
  498. ! #ident    "@(#)winipane.c    1.2 olvwm version 1/27/92"
  499. X  
  500. X  /*
  501. X   * Based on
  502. --- 4,10 ----
  503. X   *      file for terms of the license.
  504. X   */
  505. X  
  506. ! #ident    "@(#)winipane.c    1.3 olvwm version 6/13/92"
  507. X  
  508. X  /*
  509. X   * Based on
  510. ***************
  511. *** 439,444 ****
  512. --- 439,454 ----
  513. X  
  514. X      /* register the window */
  515. X      WIInstallInfo(w);
  516. +     /* Reparent the pane.  olwm didn't do this; since it never moved the
  517. +      * icon while it was in StateNorm, it could afford to unparent the
  518. +      * icon everytime it went to StateNorm.  We can't do that, or the
  519. +      * icon misses ConfigureNotify events when its not visible
  520. +      */
  521. +     XReparentWindow(cli->dpy, iconPane, par->core.self,
  522. +             w->core.x, w->core.y);
  523. +     if (w->iconClientWindow && !(cli->flags & CLOlwmOwned))
  524. +         XChangeSaveSet(cli->dpy, w->core.self, SetModeInsert);
  525. X  
  526. X      return w;
  527. X  }
  528. *** BUILD/winresize.c    Sat Jun 13 15:50:11 1992
  529. --- src/winresize.c    Sat Jun 13 15:43:31 1992
  530. ***************
  531. *** 4,10 ****
  532. X   *      file for terms of the license.
  533. X   */
  534. X  
  535. ! #ident    "@(#)winresize.c    1.1 olvwm version 1/3/92"
  536. X  
  537. X  /*
  538. X   * Based on
  539. --- 4,10 ----
  540. X   *      file for terms of the license.
  541. X   */
  542. X  
  543. ! #ident    "@(#)winresize.c    1.2 olvwm version 6/13/92"
  544. X  
  545. X  /*
  546. X   * Based on
  547. ***************
  548. *** 240,246 ****
  549. X          ButtonPressMask | ButtonMotionMask | ButtonReleaseMask
  550. X          | ExposureMask | OwnerGrabButtonMask;
  551. X          attributes.win_gravity = whichgrav[which];
  552. !     attributes.cursor = GRV.ResizePointer;
  553. X          valuemask = CWEventMask | CWWinGravity | CWCursor;
  554. X  
  555. X          win = XCreateWindow(dpy, par->core.self,
  556. --- 240,248 ----
  557. X          ButtonPressMask | ButtonMotionMask | ButtonReleaseMask
  558. X          | ExposureMask | OwnerGrabButtonMask;
  559. X          attributes.win_gravity = whichgrav[which];
  560. !     if (GRV.SpecialResizePointers)
  561. !         attributes.cursor = GRV.CornerPointers[which];
  562. !     else attributes.cursor = GRV.ResizePointer;
  563. X          valuemask = CWEventMask | CWWinGravity | CWCursor;
  564. X  
  565. X          win = XCreateWindow(dpy, par->core.self,
  566. *** BUILD/cursors.c    Sat Jun 13 15:55:20 1992
  567. --- src/cursors.c    Sat Jun 13 15:48:00 1992
  568. ***************
  569. *** 0 ****
  570. --- 1,412 ----
  571. + #include <stdio.h>
  572. + #include <memory.h>
  573. + #include <X11/Xos.h>
  574. + #include <X11/Xlib.h>
  575. + #include <X11/Xutil.h>
  576. + #include <X11/Xresource.h>
  577. + #include <X11/keysym.h>
  578. + #include <X11/cursorfont.h>
  579. + #include "olcursor.h"
  580. + #include "ollocale.h"
  581. + #include "mem.h"
  582. + #include "olwm.h"
  583. + #include "win.h"
  584. + #include "menu.h"
  585. + #include "globals.h"
  586. + #include "screen.h"
  587. + #include "cursors.h"
  588. + #include "i18n.h"
  589. + #include "st.h"
  590. + #ident "@(#)cursors.c    1.1 olvwm version 6/13/92"
  591. + static st_table    *cursorTable;
  592. + static st_table *fontTable;
  593. + typedef struct _cursor_data {
  594. +     char *name;
  595. +     int num;
  596. + };
  597. + static struct _cursor_data cursor_names[] = {
  598. +     { "XC_num_glyphs", XC_num_glyphs },
  599. +     { "XC_X_cursor", XC_X_cursor },
  600. +     { "XC_arrow", XC_arrow },
  601. +     { "XC_based_arrow_down", XC_based_arrow_down },
  602. +     { "XC_based_arrow_up", XC_based_arrow_up },
  603. +     { "XC_boat", XC_boat },
  604. +     { "XC_bogosity", XC_bogosity },
  605. +     { "XC_bottom_left_corner", XC_bottom_left_corner },
  606. +     { "XC_bottom_right_corner", XC_bottom_right_corner },
  607. +     { "XC_bottom_side", XC_bottom_side },
  608. +     { "XC_bottom_tee", XC_bottom_tee },
  609. +     { "XC_box_spiral", XC_box_spiral },
  610. +     { "XC_center_ptr", XC_center_ptr },
  611. +     { "XC_circle", XC_circle },
  612. +     { "XC_clock", XC_clock },
  613. +     { "XC_coffee_mug", XC_coffee_mug },
  614. +     { "XC_cross", XC_cross },
  615. +     { "XC_cross_reverse", XC_cross_reverse },
  616. +     { "XC_crosshair", XC_crosshair },
  617. +     { "XC_diamond_cross", XC_diamond_cross },
  618. +     { "XC_dot", XC_dot },
  619. +     { "XC_dotbox", XC_dotbox },
  620. +     { "XC_double_arrow", XC_double_arrow },
  621. +     { "XC_draft_large", XC_draft_large },
  622. +     { "XC_draft_small", XC_draft_small },
  623. +     { "XC_draped_box", XC_draped_box },
  624. +     { "XC_exchange", XC_exchange },
  625. +     { "XC_fleur", XC_fleur },
  626. +     { "XC_gobbler", XC_gobbler },
  627. +     { "XC_gumby", XC_gumby },
  628. +     { "XC_hand1", XC_hand1 },
  629. +     { "XC_hand2", XC_hand2 },
  630. +     { "XC_heart", XC_heart },
  631. +     { "XC_icon", XC_icon },
  632. +     { "XC_iron_cross", XC_iron_cross },
  633. +     { "XC_left_ptr", XC_left_ptr },
  634. +     { "XC_left_side", XC_left_side },
  635. +     { "XC_left_tee", XC_left_tee },
  636. +     { "XC_leftbutton", XC_leftbutton },
  637. +     { "XC_ll_angle", XC_ll_angle },
  638. +     { "XC_lr_angle", XC_lr_angle },
  639. +     { "XC_man", XC_man },
  640. +     { "XC_middlebutton", XC_middlebutton },
  641. +     { "XC_mouse", XC_mouse },
  642. +     { "XC_pencil", XC_pencil },
  643. +     { "XC_pirate", XC_pirate },
  644. +     { "XC_plus", XC_plus },
  645. +     { "XC_question_arrow", XC_question_arrow },
  646. +     { "XC_right_ptr", XC_right_ptr },
  647. +     { "XC_right_side", XC_right_side },
  648. +     { "XC_right_tee", XC_right_tee },
  649. +     { "XC_rightbutton", XC_rightbutton },
  650. +     { "XC_rtl_logo", XC_rtl_logo },
  651. +     { "XC_sailboat", XC_sailboat },
  652. +     { "XC_sb_down_arrow", XC_sb_down_arrow },
  653. +     { "XC_sb_h_double_arrow", XC_sb_h_double_arrow },
  654. +     { "XC_sb_left_arrow", XC_sb_left_arrow },
  655. +     { "XC_sb_right_arrow", XC_sb_right_arrow },
  656. +     { "XC_sb_up_arrow", XC_sb_up_arrow },
  657. +     { "XC_sb_v_double_arrow", XC_sb_v_double_arrow },
  658. +     { "XC_shuttle", XC_shuttle },
  659. +     { "XC_sizing", XC_sizing },
  660. +     { "XC_spider", XC_spider },
  661. +     { "XC_spraycan", XC_spraycan },
  662. +     { "XC_star", XC_star },
  663. +     { "XC_target", XC_target },
  664. +     { "XC_tcross", XC_tcross },
  665. +     { "XC_top_left_arrow", XC_top_left_arrow },
  666. +     { "XC_top_left_corner", XC_top_left_corner },
  667. +     { "XC_top_right_corner", XC_top_right_corner },
  668. +     { "XC_top_side", XC_top_side },
  669. +     { "XC_top_tee", XC_top_tee },
  670. +     { "XC_trek", XC_trek },
  671. +     { "XC_ul_angle", XC_ul_angle },
  672. +     { "XC_umbrella", XC_umbrella },
  673. +     { "XC_ur_angle", XC_ur_angle },
  674. +     { "XC_watch", XC_watch },
  675. +     { "XC_xterm", XC_xterm },
  676. +     { "OLC_basic", OLC_basic },
  677. +     { "OLC_move", OLC_move },
  678. +     { "OLC_copy", OLC_copy },
  679. +     { "OLC_busy", OLC_busy },
  680. +     { "OLC_stop", OLC_stop },
  681. +     { "OLC_panning", OLC_panning },
  682. +     { "OLC_target", OLC_target },
  683. +     { "OLC_nouse", OLC_nouse },
  684. +     { "OLC_ptr", OLC_ptr },
  685. +     { "OLC_beye", OLC_beye },
  686. +     { "OLC_rtarr", OLC_rtarr },
  687. +     { "OLC_xhair", OLC_xhair },
  688. +     { "OLC_xcurs", OLC_xcurs },
  689. +     { "OLC_hourg", OLC_hourg },
  690. +     { NULL, -1 }
  691. + };
  692. + static int
  693. + cursorHash(a, modulus)
  694. +     register char    *a;
  695. +     register int    modulus;
  696. + {
  697. + int    sum = 0;
  698. +     while (*a)
  699. +     sum += *a++;
  700. +     return sum % modulus;
  701. + }
  702. + #define DEFAULT_CURSOR    XC_left_ptr
  703. + static Font
  704. + resLoadFont(dpy, file)
  705. +     Display *dpy;
  706. +     char *file;
  707. + {
  708. +     Font fid;
  709. +     if (!fontTable)
  710. +     fontTable = st_init_table(strcmp, cursorHash);
  711. +     
  712. +     if (!st_lookup(fontTable, file, &fid)) {
  713. +     if ((fid = XLoadFont(dpy, file)) == 0)
  714. +         fid = (Font) 0;
  715. +     else st_insert(fontTable, file, (char *) fid);
  716. +     }
  717. +     return fid;
  718. + }
  719. + static Bool
  720. + findNextColor(dpy, ptr, xcolor, cmap)
  721. +     Display *dpy;
  722. +     char **ptr;
  723. +     XColor *xcolor;
  724. +     Colormap cmap;
  725. + {
  726. + char *color, tmp;
  727. + Bool return_flag = True;
  728. +     for ( ; **ptr && isspace(**ptr); ++(*ptr))
  729. +     ;    /* read to next space */
  730. +     if (**ptr == '\0')
  731. +     return_flag = False;
  732. +     else {
  733. +     color = *ptr;
  734. +     for ( ; **ptr && !isspace( **ptr ); ++(*ptr) )
  735. +         ;    /* read to next space */
  736. +     tmp = **ptr;
  737. +     **ptr = '\0';
  738. +     if (!XParseColor(dpy, cmap, color, xcolor) ||
  739. +         !XAllocColor(dpy, cmap, xcolor))
  740. +         return_flag = False;
  741. +     **ptr = tmp;
  742. +     }
  743. +     return return_flag;
  744. + }
  745. + static void
  746. + createCursor(dpy, cmap, pointer, cursor_id, font_file, no_colors, colors_p)
  747. +     Display *dpy;
  748. +     Colormap cmap;
  749. +     Cursor *pointer;
  750. +     int cursor_id;
  751. +     char *font_file;
  752. +     Bool no_colors;
  753. +     char *colors_p;
  754. + {
  755. +     static XColor def_bg, def_fg;
  756. +     static Bool def_cols_set = False;
  757. +     XColor fg, bg;
  758. +     Font fid;
  759. +     Bool use_default = False;
  760. +     if (!def_cols_set) {
  761. +     def_fg.pixel = BlackPixel(dpy, DefaultScreen(dpy));
  762. +     XQueryColor(dpy, cmap, &def_fg);
  763. +     def_bg.pixel = WhitePixel(dpy, DefaultScreen(dpy));
  764. +     XQueryColor(dpy, cmap, &def_bg);
  765. +     def_cols_set = True;
  766. +     }
  767. +     if (no_colors) {
  768. +     fg = def_fg;
  769. +     bg = def_bg;
  770. +     }
  771. +     else {
  772. +     char *p = colors_p;
  773. +     if (findNextColor(dpy, (++p, &p), &fg, cmap)) {
  774. +         if (!*p || !findNextColor(dpy, (++p, &p), &bg, cmap))
  775. +         bg = def_bg;
  776. +     }
  777. +     else {
  778. +         fg = def_fg;
  779. +         bg = def_bg;
  780. +     }
  781. +     }
  782. +     if (font_file == NULL || (fid = resLoadFont(dpy, font_file)) == 0)
  783. +     use_default = True;
  784. +     else {
  785. +     if ((*pointer = XCreateGlyphCursor(dpy, fid, fid, cursor_id,
  786. +                          cursor_id+1, &fg, &bg )) == NULL)
  787. +         use_default = True;
  788. +     }
  789. +     if (use_default) {
  790. +     *pointer = XCreateFontCursor(dpy, DEFAULT_CURSOR);
  791. +     XRecolorCursor(dpy, *pointer, &def_fg, &def_bg);
  792. +     }
  793. + }
  794. + static void
  795. + initPointer(dpy, cmap, data, pointer)
  796. +     Display *dpy;
  797. +     Colormap cmap;
  798. +     char *data;
  799. +     Cursor *pointer;
  800. + {
  801. +     char *our_copy, *ptr;
  802. +     Bool end = False;
  803. +     int cursor_id;
  804. +     char *font_file = NULL;
  805. +     char *cursor_id_p;
  806. +     if (data) {
  807. +     our_copy = MemNewString(data);
  808. +     for (ptr = our_copy; *ptr && !isspace( *ptr ); ++ptr)
  809. +         ;
  810. +     if ( *ptr == '\0' )
  811. +         end = True;
  812. +     else *ptr = '\0';
  813. +         
  814. +     if (st_lookup(cursorTable, our_copy, &cursor_id)) {
  815. +         if (our_copy[0] == 'X')
  816. +         font_file = "cursor";
  817. +         else if (our_copy[0] == 'O')
  818. +         font_file = "olcursor";
  819. +         createCursor(dpy, cmap, pointer, cursor_id, font_file, end, ptr);
  820. +     }
  821. +     else {
  822. +         if (end)
  823. +         createCursor(dpy, cmap, pointer, 0, NULL, end, ptr);
  824. +         
  825. +         font_file = our_copy;
  826. +         for (++ptr; *ptr && isspace( *ptr ); ++ptr)
  827. +         ;
  828. +         cursor_id_p = ptr;
  829. +         for (; *ptr && !isspace( *ptr ); ++ptr )
  830. +         ;
  831. +         if ( *ptr == '\0' )
  832. +         end = True;
  833. +         else *ptr = '\0';
  834. +         
  835. +         cursor_id = atoi(cursor_id_p);
  836. +         createCursor(dpy, cmap, pointer, cursor_id, font_file, end, ptr);
  837. +     }
  838. +     MemFree( our_copy );
  839. +     }
  840. + }
  841. + static void
  842. + initOtherPointers(dpy, cmap)
  843. +     Display *dpy;
  844. +     Colormap cmap;
  845. + {
  846. +     initPointer(dpy, cmap, GRV.BasicPointerData, &GRV.BasicPointer);
  847. +     initPointer(dpy, cmap, GRV.MovePointerData, &GRV.MovePointer);
  848. +     initPointer(dpy, cmap, GRV.BusyPointerData, &GRV.BusyPointer);
  849. +     initPointer(dpy, cmap, GRV.IconPointerData, &GRV.IconPointer);
  850. +     initPointer(dpy, cmap, GRV.ResizePointerData, &GRV.ResizePointer);
  851. +     initPointer(dpy, cmap, GRV.MenuPointerData, &GRV.MenuPointer);
  852. +     initPointer(dpy, cmap, GRV.QuestionPointerData, &GRV.QuestionPointer);
  853. +     initPointer(dpy, cmap, GRV.TargetPointerData, &GRV.TargetPointer);
  854. +     initPointer(dpy, cmap, GRV.PanPointerData, &GRV.PanPointer);
  855. +     initPointer(dpy, cmap, GRV.CloseUpPointerData, &GRV.CloseUpPointer);
  856. +     initPointer(dpy, cmap, GRV.CloseDownPointerData, &GRV.CloseDownPointer);
  857. + }
  858. + static Bool
  859. + initResizePointers(dpy, cmap)
  860. +     Display *dpy;
  861. +     Colormap cmap;
  862. + {
  863. + char *ptr;
  864. + Bool colorsIncluded = False;
  865. + char *our_copy;
  866. + XColor colFGC, colBGC, colFGM, colBGM;
  867. + int i;
  868. +     if (GRV.SpecialResizePointerData) {
  869. +     our_copy = MemNewString( GRV.SpecialResizePointerData );
  870. +     for (ptr = our_copy; *ptr && !isspace(*ptr); ++ptr)
  871. +         ;    /* get the first space in ptr */
  872. +     if (*ptr) {
  873. +         colorsIncluded = True;
  874. +         *ptr = '\0';
  875. +     }
  876. +     if (matchBool(our_copy, &GRV.SpecialResizePointers) == True ) {
  877. +         /* Turn on cursors */
  878. +         /* Arrays are in order of enum WhichResize, defined in win.h */
  879. +         GRV.CornerPointers[0] = XCreateFontCursor(dpy, XC_ul_angle);
  880. +         GRV.CornerPointers[1] = XCreateFontCursor(dpy, XC_ur_angle);
  881. +         GRV.CornerPointers[2] = XCreateFontCursor(dpy, XC_ll_angle);
  882. +         GRV.CornerPointers[3] = XCreateFontCursor(dpy, XC_lr_angle);
  883. +         GRV.ResizePointers[0] =
  884. +                   XCreateFontCursor(dpy, XC_top_left_corner);
  885. +         GRV.ResizePointers[1] =
  886. +                   XCreateFontCursor(dpy, XC_top_right_corner);
  887. +         GRV.ResizePointers[2] =
  888. +                   XCreateFontCursor(dpy, XC_bottom_left_corner);
  889. +         GRV.ResizePointers[3] =
  890. +                   XCreateFontCursor(dpy, XC_bottom_right_corner);
  891. +         
  892. +         if (colorsIncluded) {
  893. +         if (!findNextColor(dpy, (++ptr, &ptr), &colFGC, cmap) ||
  894. +            !*ptr || !findNextColor(dpy, (++ptr, &ptr), &colBGC, cmap) ||
  895. +            !*ptr || !findNextColor(dpy, (++ptr, &ptr), &colFGM, cmap) ||
  896. +            !*ptr || !findNextColor(dpy, (++ptr, &ptr), &colBGM, cmap)) {
  897. +             ErrorWarning(gettext("Bad color specification for special resize cursor"));
  898. +             colorsIncluded = False;
  899. +         }
  900. +         }
  901. +         if (!colorsIncluded) {
  902. +         /* if not included, get default colors */
  903. +         colFGC.pixel = BlackPixel(dpy, DefaultScreen(dpy));
  904. +         XQueryColor(dpy, cmap, &colFGC);
  905. +         colBGC.pixel = WhitePixel(dpy, DefaultScreen(dpy));
  906. +         XQueryColor(dpy, cmap, &colBGC);
  907. +         colFGM = colFGC;
  908. +         colBGM = colBGC;
  909. +         }
  910. +         for (i = 0; i < 4; ++i) {
  911. +         XRecolorCursor(dpy, GRV.CornerPointers[i], &colFGC, &colBGC);
  912. +         XRecolorCursor(dpy, GRV.ResizePointers[i], &colFGM, &colBGM);
  913. +         }
  914. +     }
  915. +     MemFree(our_copy);
  916. +     }
  917. +     else return False;
  918. +     return True;
  919. + }
  920. + /*
  921. +  *
  922. +  * ============================================================================
  923. +  * Entry Points
  924. +  */
  925. + void
  926. + InitCursors(dpy, scrInfo)
  927. +     Display *dpy;
  928. +     ScreenInfo *scrInfo;
  929. + {
  930. + Colormap cmap;
  931. + struct _cursor_data    *p;
  932. +     cmap = scrInfo->colormap;
  933. +     cursorTable = st_init_table(strcmp, cursorHash);
  934. +     for (p = cursor_names; p->name; p++)
  935. +     st_insert(cursorTable, (int) p->name, (char *) p->num);
  936. +     if (!initResizePointers(dpy, cmap))
  937. +     GRV.SpecialResizePointers = False;
  938. +     initOtherPointers(dpy, cmap);
  939. + }
  940. *** BUILD/cursors.h    Sat Jun 13 15:55:23 1992
  941. --- src/cursors.h    Sat Jun 13 15:48:00 1992
  942. ***************
  943. *** 0 ****
  944. --- 1,9 ----
  945. + #ifndef _OLWM_LBL_CURSORS_H
  946. + #define _OLWM_LBL_CURSORS_H
  947. + #ident "@(#)cursors.h    1.1 olvwm version 6/13/92"
  948. + extern void InitCursors( /* Display *,  ScreenInfo * */ );
  949. + extern void updateCursors( /* Display *, char * */ );
  950. + #endif
  951. SHAR_EOF
  952. echo 'File olvwm3.Patch02 is complete' &&
  953. chmod 0644 olvwm3.Patch02 ||
  954. echo 'restore of olvwm3.Patch02 failed'
  955. Wc_c="`wc -c < 'olvwm3.Patch02'`"
  956. test 174178 -eq "$Wc_c" ||
  957.     echo 'olvwm3.Patch02: original size 174178, current size' "$Wc_c"
  958. rm -f _shar_wnt_.tmp
  959. fi
  960. rm -f _shar_seq_.tmp
  961. echo You have unpacked the last part
  962. exit 0
  963. -- 
  964. ---
  965. Senior Systems Scientist        mail: dcmartin@msi.com
  966. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  967. 796 North Pastoria Avenue        at&t: 408/522-9236
  968.